package com.wang.pages.master;

import java.util.List;

import javax.inject.Inject;

import org.apache.tapestry5.annotations.PageActivationContext;
import org.apache.tapestry5.annotations.Property;

import com.wang.entities.MasterType;
import com.wang.services.StateDAO;

public class ConstructionTypeList {

//	@PageActivationContext
//	private String username;
//
//	public String getUsername() {
//		System.out.println("建设性质(编辑用户):" + username);
//		return username;
//	}
//
//	public void setUsername(String username) {
//		this.username = username;
//	}
//
//	void onActivate(String name) {
//		System.out.println("##########" + name);
//		username = name;
//	}

	// 打开user读写
	@Property
	private MasterType mastertype;

	// 打开user阵列的读写
	@Property
	private List<MasterType> mastertypes;

	/*
	 * public MasterType getMastertype() { return mastertype; }
	 * 
	 * public void setMastertype(MasterType mastertype) { this.mastertype =
	 * mastertype; }
	 * 
	 * public List<MasterType> getMastertypes() { return mastertypes; }
	 * 
	 * public void setMastertypes(List<MasterType> mastertypes) {
	 * this.mastertypes = mastertypes; }
	 * 
	 * public StateDAO getDao() { return dao; }
	 * 
	 * public void setDao(StateDAO dao) { this.dao = dao; }
	 */

	// 导入操作数据库的服务
	@Inject
	private StateDAO dao;

	 //当前页面接收user的id值
	 @PageActivationContext
	 private Long id;

	// 页面加载时设置渲染
	void setupRender() {
		// 查询User数据表
		StringBuffer sql = new StringBuffer();
		sql.append("from MasterType");
		mastertypes = dao.findWithQuery(sql.toString());
	}

	// 单击eventlink执行删除操作
	Object onDelete(Long id) {
		dao.deleteByID(MasterType.class, id);
		return this;
	}
}
